/**
 * Copyright @ 2000 ysten Co. Ltd. 
 * All right reserved.     
 * @author: wangmin
 * date: 2016-07-11     
 */
package com.task.entity;

import javax.persistence.*;

import com.task.bean.EnumConstants;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import java.io.Serializable;
import java.util.Date;

/**
 * 子任务
 */
@Entity
@Table(name = "tufa_child_task")
public class ChildTask implements Serializable {
	private static final long serialVersionUID = 3471217958393102289L;

	@Id
	@GeneratedValue
	private Long id;

	// 主任务外键
	@Column(name = "parent_task_id")
	private Long parentTaskId;

	// 子任务名称
	private String taskName;

	// 关联门店信息
	@OneToOne
	@JoinColumn(name = "store_code", referencedColumnName = "storeCode", insertable = false, updatable = false)
	private Store store;

	@Column(name = "store_code")
	private String storeCode;

	// 接单人
	private String userId;

	// 接单时间
	@Column(name = "pickup_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date pickUpTime;

	// 完成时间
	@Column(name = "finish_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date finishTime;

	// 子任务状态
	@Enumerated(EnumType.STRING)
	private EnumConstants.ChildTaskStatus status;

	// 子任务编码（唯一：主任务编号+“-”+4位序号）
	@Column(unique = true)
	private String code;

	// 子任务赏金
	private Float reward;

	// 关联主任务信息
	@OneToOne
	@JoinColumn(name = "parent_task_id", referencedColumnName = "id", insertable = false, updatable = false)
	private ParentTask parentTask;

	// 子任务临时序号编码
	@Transient
	private String childTaskCode;

	/**
	 * 父任务类型
	 */
	@Formula(value = "(select t.task_type from tufa_parent_task t where t.id=parent_task_id)")
	@JsonIgnore
	private String taskType;

	/**
	 * 父任务结束时间
	 */
	@Formula(value = "(select t.end_time from tufa_parent_task t where t.id=parent_task_id)")
	@JsonIgnore
	private String endTime;

    /**
     * 纬度
     */
    private Float latitude;

    /**
     * 经度
     */
    private Float longitude;

    /**
     * 抢单地理位置
     */
    private String pickAddress;

    public Float getLatitude() {
        return latitude;
    }

    public void setLatitude(Float latitude) {
        this.latitude = latitude;
    }

    public Float getLongitude() {
        return longitude;
    }

    public void setLongitude(Float longitude) {
        this.longitude = longitude;
    }

    public String getPickAddress() {
        return pickAddress;
    }

    public void setPickAddress(String pickAddress) {
        this.pickAddress = pickAddress;
    }

    public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	public Float getReward() {
		return reward;
	}

	public void setReward(Float reward) {
		this.reward = reward;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getParentTaskId() {
		return parentTaskId;
	}

	public void setParentTaskId(Long parentTaskId) {
		this.parentTaskId = parentTaskId;
	}

	public String getTaskName() {
		return taskName;
	}

	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public Date getPickUpTime() {
		return pickUpTime;
	}

	public void setPickUpTime(Date pickUpTime) {
		this.pickUpTime = pickUpTime;
	}

	public Date getFinishTime() {
		return finishTime;
	}

	public void setFinishTime(Date finishTime) {
		this.finishTime = finishTime;
	}

	public EnumConstants.ChildTaskStatus getStatus() {
		return status;
	}

	public void setStatus(EnumConstants.ChildTaskStatus status) {
		this.status = status;
	}

	public ParentTask getParentTask() {
		return parentTask;
	}

	public void setParentTask(ParentTask parentTask) {
		this.parentTask = parentTask;
	}

	public String getStoreCode() {
		return storeCode;
	}

	public void setStoreCode(String storeCode) {
		this.storeCode = storeCode;
	}

	public String getChildTaskCode() {
		return childTaskCode;
	}

	public void setChildTaskCode(String childTaskCode) {
		this.childTaskCode = childTaskCode;
	}

	public String getTaskType() {
		return taskType;
	}

	public void setTaskType(String taskType) {
		this.taskType = taskType;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

}
